package team.pwy.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import team.pwy.pojo.dto.OrderDTO;
import team.pwy.pojo.entity.Order;

import java.util.List;

/**
 * 本来用来演示:
 *
 * @author feng
 * @date 2023/10/23
 * @Description
 */
@Repository
public interface OrderMapper {

    @Delete("delete from pwy.pwy_order where id = #{id}")
    int deleteByIdAndUserId(@Param("id") int id);

    int addOrder(OrderDTO orderDTO);

    @Select("select * from pwy.pwy_order where id = #{value}")
    Order findById(int id);

    @Update("update pwy.pwy_order set status = #{payStatus} where id = #{id};")
    int updateById(@Param("id") int id , @Param("payStatus") int payStatus);

    // 即将放映订单
    @Select("select * from pwy.pwy_order where session_id = #{value}")
    List<Order> findStart(int sessionId);

    @Select("select id from pwy.pwy_seat where order_id = #{value}")
    List<Integer> findByOrderId(int orderId);

}
